package com.suineg.pms.commons;

import javax.servlet.ServletContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 *
 *@author Suine
 */
public class AppConfig {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	private static AppConfig appConfig = null;
	
	private ServletContext application;
	
	@SuppressWarnings("unused")
	private WebApplicationContext wac;
	
	private AppConfig() {
	}

	public static AppConfig getInstance(){
		if(appConfig == null){
			appConfig =  new AppConfig();
		}
		return appConfig;
	}

	public WebApplicationContext getWac() {
		if(application == null){
			return null;
		}
		return WebApplicationContextUtils.getRequiredWebApplicationContext(application);
	}


	public ServletContext getApplication() {
		return application;
	}
	
	public void setApplication(ServletContext application) {
		this.application = application;
	}

	public void setWac(WebApplicationContext wac) {
		this.wac = wac;
	}
}

